<nz-card>
  <!-- S 基础信息 -->
  <div class="form-item-wrap">
    <p class="item-title">
      <i nz-icon nzType="subnode" nzTheme="outline" class="t-icon"></i>
      基础信息
    </p>
    
    <div class="item-control">
      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>优惠券类型</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group
            [(ngModel)]="formParams.type"
            (ngModelChange)="couponTypeChange($event)">
            <label nz-radio [nzValue]="1">满减券</label>
            <label nz-radio [nzValue]="2">折扣券</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>优惠券名称</nz-form-label>
        <nz-form-control nzFlex="400px">
          <input nz-input maxlength="10" placeholder="请输入,前端用户可见" [(ngModel)]="formParams.name" />
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>优惠券规则</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-textarea-count [nzMaxCharacterCount]="100">
            <textarea
              rows="4"
              nz-input
              maxlength="100"
              placeholder="前端可见"
              [(ngModel)]="formParams.useDesc"
            ></textarea>
          </nz-textarea-count>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px">备注</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-textarea-count [nzMaxCharacterCount]="30">
            <textarea
              rows="4"
              nz-input
              maxlength="30"
              placeholder="仅内部可见"
              [(ngModel)]="formParams.remark"
            ></textarea>
          </nz-textarea-count>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>发放总量</nz-form-label>
        <nz-form-control>
          <div class="form-item-flex">
            <nz-input-number
              style="width: 120px;"
              [nzMin]="1"
              [nzMax]="100000"
              [nzStep]="1"
              [nzPrecision]="0"
              nzPlaceHolder="请输入"
              [(ngModel)]="formParams.total"
            ></nz-input-number>
            <span class="p-l-6">张</span>
          </div>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>使用门槛</nz-form-label>
        <nz-form-control>
          <div class="form-item-flex">
            <span class="p-r-6">订单满</span>
            <nz-input-number
              style="width: 120px;"
              [nzMin]="0"
              [nzMax]="100000"
              [nzStep]="1"
              [nzPrecision]="0"
              nzPlaceHolder="请输入"
              [(ngModel)]="formParams.orderLimitMoney"
              (nzBlur)="thresholdVerif()"
            ></nz-input-number>
            <span class="p-l-6">元可用</span>
          </div>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item *ngIf="formParams.type === 1">
        <nz-form-label nzFlex="120px" nzRequired>减免额度</nz-form-label>
        <nz-form-control nzFlex="500px">
          <nz-input-number
            style="width: 120px;"
            [nzMin]="1"
            [nzMax]="10000"
            [nzPrecision]="0"
            [nzStep]="1"
            nzPlaceHolder="请输入"
            [(ngModel)]="formParams.limitSmall"
            (nzBlur)="reductionVerif(0)"
          ></nz-input-number>

          <span class="p-l-6">元</span>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item *ngIf="formParams.type === 2">
        <nz-form-label nzFlex="120px" nzRequired>折扣力度</nz-form-label>
        <nz-form-control nzFlex="500px">
          <nz-input-number
            style="width: 120px;"
            [nzMin]="0.1"
            [nzStep]="0.1"
            [nzMax]="9.9"
            [nzPrecision]="1"
            nzPlaceHolder="请输入"
            [(ngModel)]="formParams.limitSmall"
          ></nz-input-number>

          <span class="p-l-6">折</span>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item *ngIf="formParams.type === 2">
        <nz-form-label nzFlex="120px" nzRequired>最高减免</nz-form-label>
        <nz-form-control>
          <div class="form-item-flex">
            <nz-input-number
              style="width: 120px;"
              [nzMin]="1"
              [nzMax]="100000"
              [nzStep]="1"
              [nzPrecision]="0"
              nzPlaceHolder="请输入"
              [(ngModel)]="formParams.limitBig"
            ></nz-input-number>

            <span class="p-l-6">元</span>
          </div>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
  <!-- E 基础信息 -->

  <nz-divider></nz-divider>

  <!-- S 使用设置 -->
  <div class="form-item-wrap">
    <p class="item-title">
      <i nz-icon nzType="subnode" nzTheme="outline" class="t-icon"></i>
      使用设置
    </p>

    <div class="item-control">
      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>领取人限制</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="formParams.userType">
            <label
              *ngFor="let o of userTypeOptions"
              nz-radio
              [nzValue]="o.value"
            >{{ o.label }}</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>前端展示</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="formParams.isShowWeb" (ngModelChange)="isShowChange($event)">
            <label nz-radio [nzValue]="1">展示</label>
            <label nz-radio [nzValue]="0">不展示</label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item *ngIf="formParams.isShowWeb === 1">
        <nz-form-label nzFlex="120px" nzRequired>可领取时间</nz-form-label>
        <nz-form-control nzFlex="500px">
          <nz-range-picker
            [nzShowTime]="true"
            [nzShowTime]="{ nzFormat: 'HH:mm:ss' }"
            nzFormat="yyyy-MM-dd HH:mm:ss"
            [(ngModel)]="receiveDates"
            (ngModelChange)="onDateChange($event, ['getBeginTime', 'getEndTime'])"
          ></nz-range-picker>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>有效期</nz-form-label>
        <nz-form-control nzFlex="400px">
          <nz-radio-group [(ngModel)]="effectiveType" (ngModelChange)="effectiveChange($event)">
            <label nz-radio [nzValue]="1">
              <span class="p-r-6">领取当日起</span>
              <nz-input-number
                [nzMin]="1"
                [nzStep]="1"
                [(ngModel)]="formParams.limitTimeNum"
                [nzDisabled]="effectiveType === 2"
              ></nz-input-number>
              <span class="p-l-6">天内可用</span>
            </label>

            <label nz-radio [nzValue]="2" class="m-t-15">
              <nz-range-picker
                [nzShowTime]="true"
                [nzShowTime]="{ nzFormat: 'HH:mm:ss' }"
                nzFormat="yyyy-MM-dd HH:mm:ss"
                [(ngModel)]="effectiveDates"
                (ngModelChange)="onDateChange($event, ['useBeginTime', 'useEndTime'])"
                [nzDisabled]="effectiveType === 1"
              ></nz-range-picker>
            </label>
          </nz-radio-group>
        </nz-form-control>
      </nz-form-item>

      <nz-form-item>
        <nz-form-label nzFlex="120px" nzRequired>适用品类</nz-form-label>
        <nz-form-control nzFlex="520px">
          <zdy-checkbox-group
            *ngIf="categoryOptions.length"
            [checkOptions]="categoryOptions"
            [checkKeys]="{
              key: 'groupId',
              label: 'textureName'
            }"
            [isAllCheck]="false"
            [(ngModel)]="selectedCategory"
          ></zdy-checkbox-group>
        </nz-form-control>
      </nz-form-item>
    </div>
  </div>
  <!-- E 使用设置 -->
</nz-card>

<nz-card class="m-t-4">
  <div nz-row nzJustify="center" nzAlign="top">
    <button
      *ngIf="formParams.status === 5 && routeParams.id && routeParams.type == 1"
      nz-button
      nzType="primary"
      class="m-r-10"
      [disabled]="submitReviewLoading"
      (click)="submitForm(6)"
    >提交审核</button>

    <button
      *ngIf="formParams.status === 6"
      nz-button
      nzType="primary"
      class="m-r-10"
      [nzLoading]="examineLoading"
      (click)="showExamineModal()"
    >审核</button>

    <button
      nz-button
      nzType="primary"
      class="m-r-10"
      [nzLoading]="submitFormLoading"
      (click)="submitForm()"
    >保存</button>
    
    <button
      nz-button
      nzType="dashed"
      (click)="back()"
    >返回</button>
  </div>
</nz-card>

<!-- S 审核Modal -->
<nz-modal
  nzClassName="custom-model-wrap"
  [nzFooter]="null"
  [(nzVisible)]="isExamineVisible"
  [nzTitle]="'审核'"
  (nzOnCancel)="isExamineVisible = false">

  <div *nzModalContent>
    <div class="custom-model-body">
      <nz-textarea-count [nzMaxCharacterCount]="100">
        <textarea rows="4" nz-input placeholder="请输入审核意见" [(ngModel)]="examineParams.remark"></textarea>
      </nz-textarea-count>
    </div>

    <div class="custom-model-foot">
      <div class="custom-foot-cont">
        <button nz-button nzType="primary" (click)="subExamine(1)">审核通过</button>
        <button nz-button nzType="primary" nzDanger (click)="subExamine(7)">审核不通过</button>
      </div>
    </div>
  </div>
</nz-modal>
<!-- E 审核Modal -->